<template>
  <div class="sort-nav">
    <form ref="navform">
      
      <SortNavList :childrenArr="navArr"  ></SortNavList>
      
    </form>
    <Button type="primary" icon="checkmark-circled" @click="getForm">Primary</Button>
  </div>
</template>

<script>

export default {
  name: 'SortNav',
  data () {
    return {
      //navArr:[]
    }
  },
  mounted () {
    //this.getNavArr();
  },
  computed:{
    navArr:function(){
      return this.$comFun.listToTree(this.$store.state.base.navArr)
    }
  },
  methods:{
    getNavArr:function(){
      this.$http.get('/nav')
      .then((response)=>{
        this.navArr=this.$comFun.listToTree(response.data);
      });
    },
    getForm:function(){
      let form = new FormData(this.$refs.navform);
      this.$http({
        method: 'post',
        url:"/nav/setnavtree",
        data:form
      })
      .then((response)=>{
        this.$store.dispatch('getNavArr');
        this.$Message.success({
          content:"修改成功",
          top: 50,
          duration: 3
        });
      });
    }

  }
}  
</script>
<style>
  .placeholder-style{
    background: #85cfc7;
  } 
  .sort-nav-list{
    padding:0.5rem;
  }
</style>
